<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link type="text/css" rel="stylesheet" href="../../css/templates/pager_style.css"/>
    <style>
        #tip{
            font-size: 12px;
            margin-bottom: 10px;
        }
        #letter-tip{
            color: #bbb;
            font-size: 10px;
            text-align: right;
            position: relative;
            top:-25px;
            right: 10px;
        }
        textarea{
            width: 100%;
            min-height: 100px;
            resize: none;
            box-sizing: border-box;
            color: #333;
        }
        #confirm-btn{
            width: 80px;

        }
        .btn-div{
            text-align: center;
            position: relative;
            top: -10px;
        }
    </style>
</head>
<body onload="loadData()">
    <div id="">
        <div>
            <div id="tip">
            请输入举报的详细内容（选填）
            </div>
            <textarea placeholder="==="></textarea>
            <div id="letter-tip">
            <span>还能输入<span id="left-letter">200</span>字</span>
            </div>
            <div class="btn-div">
            <button class="my-button" id="confirm-btn" onclick="report()">确定</button>
            </div>
        </div>
    </div>
    <script src="../../lib/layui/layui.js"></script>
    <script src="../../lib/jquery-3.7.0.js"></script>
    <script src="../../js/tools.js"></script>
    <script>
        var postId = getQueryVariable("postId");
        var replyId = getQueryVariable("replyId");
        var index = parent.layer.getFrameIndex(window.name);

        function report(){
            if(postId === false && replyId === false){
                parent.layer.msg("未选择/读取到举报内容")
                parent.layer.close(index);
            }
            $.post({
                url: 'http://localhost:8080/report/addOne',
                async:false,
                method: 'POST',
                crossDomain: true,
                xhrFields: { withCredentials: true },
                data:{
                    content: $("textarea").val(),
                    postId: postId === false?0 : postId,
                    replyId:replyId === false?0 : replyId
                },
                success: function (msg) {
                    parent.layer.msg(msg.msg);
                    parent.layer.close(index);
                },error:function (error){
                    parent.layer.msg("出错了！");
                    parent.layer.close(index);
                }
            })


        }
    </script>
</body>
</html>